// Made with Amplify Shader Editor v1.9.1.2
// Available at the Unity Asset Store - http://u3d.as/y3X 
Shader "Unlit/FogUnlocker"
{
    Properties
    {
//        [MainTexture] _BaseMap("Albedo", 2D) = "white" {}
        [HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
        [HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
        [ASEBegin]_MainTex("MainTex", 2D) = "white" {}
        _Amount("Amount", Range( 0 , 1)) = 0
        [ASEEnd][KeywordEnum(A,B)] _Type("Type", Float) = 0
        [HideInInspector] _texcoord( "", 2D ) = "white" {}

    }

    SubShader
    {
		LOD 0

		

        Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Transparent" "Queue"="Transparent" }

        Cull Back
        AlphaToMask Off
		HLSLINCLUDE
 
            struct InstanceParam
            {
                // float4 color;
                float4x4 instanceToObjectMatrix;
            };

		
		ENDHLSL

        
        Pass
        {
            
			Name "Forward"
			Tags { "LightMode"="UniversalForward" }

			Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
            ZWrite Off
            ZTest LEqual
//            Offset 0 , 0
            ColorMask RGBA
            

            HLSLPROGRAM
            #define _RECEIVE_SHADOWS_OFF 1
            #define ASE_SRP_VERSION 100900

            // #pragma prefer_hlslcc gles
            // 

            #pragma vertex vert
            #pragma fragment frag
            #pragma target 4.5
            
            #ifdef _GPU_BUFFER
//            #if SHADER_TARGET >= 45
            // StructuredBuffer<float4> dataBuffer;
            StructuredBuffer<InstanceParam> dataBuffer;
//            #endif
            #endif
            
			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
			#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"

            #if ASE_SRP_VERSION <= 70108
            #define REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
            #endif

            #pragma shader_feature_local _TYPE_A _TYPE_B


            struct VertexInput
            {
                float4 vertex : POSITION;
                float3 ase_normal : NORMAL;
                float4 ase_texcoord : TEXCOORD0;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct VertexOutput
            {
                float4 clipPos : SV_POSITION;
                float3 worldPos : TEXCOORD0;
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
				float4 shadowCoord : TEXCOORD1;
                #endif
                #ifdef ASE_FOG
				float fogFactor : TEXCOORD2;
                #endif
                float4 ase_texcoord3 : TEXCOORD3;
                UNITY_VERTEX_INPUT_INSTANCE_ID
                UNITY_VERTEX_OUTPUT_STEREO
            };

            CBUFFER_START(UnityPerMaterial)
            float4 _MainTex_ST;
            float _Amount;
            CBUFFER_END
            sampler2D _MainTex;


            
            VertexOutput vert(VertexInput v )
            {
                VertexOutput o = (VertexOutput)0;
                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_TRANSFER_INSTANCE_ID(v, o);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

                o.ase_texcoord3.xy = v.ase_texcoord.xy;
                
                //setting value to unused interpolator channels and avoid initialization warnings
                o.ase_texcoord3.zw = 0;
                #ifdef ASE_ABSOLUTE_VERTEX_POS
					float3 defaultVertexValue = v.vertex.xyz;
                #else
                float3 defaultVertexValue = float3(0, 0, 0);
                #endif
                float3 vertexValue = defaultVertexValue;
                #ifdef ASE_ABSOLUTE_VERTEX_POS
					v.vertex.xyz = vertexValue;
                #else
                v.vertex.xyz += vertexValue;
                #endif

                float3 positionWS = TransformObjectToWorld(v.vertex.xyz);
                float4 positionCS = TransformWorldToHClip(positionWS);

                o.worldPos = positionWS;
            	
    //             #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
				// VertexPositionInputs vertexInput = (VertexPositionInputs)0;
				// vertexInput.positionWS = positionWS;
				// vertexInput.positionCS = positionCS;
				// o.shadowCoord = GetShadowCoord( vertexInput );
    //             #endif
                #ifdef ASE_FOG
				o.fogFactor = ComputeFogFactor( positionCS.z );
                #endif
                // o.clipPos = positionCS;
				o.clipPos = positionCS ;
                return o;
            }



            half4 frag(VertexOutput IN ) : SV_Target
            {
                UNITY_SETUP_INSTANCE_ID(IN);
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);

                // #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
                
                float3 WorldPosition = IN.worldPos;
                // #endif
                
                float4 ShadowCoords = float4(0, 0, 0, 0);

                #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
						ShadowCoords = IN.shadowCoord;
                #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
						ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
                #endif
                #endif
                float2 uv_MainTex = IN.ase_texcoord3.xy * _MainTex_ST.xy + _MainTex_ST.zw;
                float4 tex2DNode5 = tex2D( _MainTex, uv_MainTex );
                float CircleArea51 = tex2DNode5.b;
                float noise52 = tex2DNode5.r;
                float shape53 = tex2DNode5.a;
                float temp_output_30_0 = step( 1.01 , ( _Amount + shape53 ) );
                #if defined(_TYPE_A)
                float staticSwitch47 = ( CircleArea51 * step( noise52 , ( CircleArea51 + (_Amount*2.0 + -1.0) ) ) );
                #elif defined(_TYPE_B)
                float staticSwitch47 = temp_output_30_0;
                #else
                float staticSwitch47 = ( CircleArea51 * step( noise52 , ( CircleArea51 + (_Amount*2.0 + -1.0) ) ) );
                #endif
                float4 appendResult58 = (float4(staticSwitch47 , staticSwitch47 , staticSwitch47 , staticSwitch47));
                
                float4 Color = appendResult58;

                #ifdef _ALPHATEST_ON
					clip( Alpha - AlphaClipThreshold );
                #endif

                #ifdef LOD_FADE_CROSSFADE
					LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
                #endif

                #ifdef ASE_FOG
					Color = MixFog( Color, IN.fogFactor );
                #endif

            	return Color;
            }
            ENDHLSL
        }

        
        Pass
        {
            
            Name "DepthOnly"
            Tags { "LightMode"="DepthOnly" }

            ZWrite On
            ColorMask 0
            AlphaToMask Off

            HLSLPROGRAM
            #define _RECEIVE_SHADOWS_OFF 1
            #define ASE_SRP_VERSION 100900

            #pragma prefer_hlslcc gles
            

            #pragma vertex vert
            #pragma fragment frag

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
            #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"

            

            struct VertexInput
            {
                float4 vertex : POSITION;
                float3 ase_normal : NORMAL;
                
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct VertexOutput
            {
                float4 clipPos : SV_POSITION;
                // #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
                float3 worldPos : TEXCOORD0;
                // #endif
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
				float4 shadowCoord : TEXCOORD1;
                #endif
                
                UNITY_VERTEX_INPUT_INSTANCE_ID
                UNITY_VERTEX_OUTPUT_STEREO
            };

            CBUFFER_START(UnityPerMaterial)

            float4 _MainTex_ST;
            float _Amount;
            CBUFFER_END
            

            
            VertexOutput vert(VertexInput v )
            {
                VertexOutput o = (VertexOutput)0;
                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_TRANSFER_INSTANCE_ID(v, o);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

                
                #ifdef ASE_ABSOLUTE_VERTEX_POS
					float3 defaultVertexValue = v.vertex.xyz;
                #else
                float3 defaultVertexValue = float3(0, 0, 0);
                #endif
                float3 vertexValue = defaultVertexValue;
                #ifdef ASE_ABSOLUTE_VERTEX_POS
					v.vertex.xyz = vertexValue;
                #else
                v.vertex.xyz += vertexValue;
                #endif

                v.ase_normal = v.ase_normal;

                float3 positionWS = TransformObjectToWorld(v.vertex.xyz);

                // #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
                o.worldPos = positionWS;
                // #endif

                o.clipPos = TransformWorldToHClip(positionWS);
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
					VertexPositionInputs vertexInput = (VertexPositionInputs)0;
					vertexInput.positionWS = positionWS;
					vertexInput.positionCS = clipPos;
					o.shadowCoord = GetShadowCoord( vertexInput );
                #endif
                return o;
            }

  

            half4 frag(VertexOutput IN ) : SV_TARGET
            {
                UNITY_SETUP_INSTANCE_ID(IN);
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);

                // #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
                
                float3 WorldPosition = IN.worldPos;
                // #endif
                
                float4 ShadowCoords = float4(0, 0, 0, 0);

                #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
						ShadowCoords = IN.shadowCoord;
                #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
						ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
                #endif
                #endif

                
                float Alpha = 1;
                float AlphaClipThreshold = 0.5;

                #ifdef _ALPHATEST_ON
					clip(Alpha - AlphaClipThreshold);
                #endif

                #ifdef LOD_FADE_CROSSFADE
					LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
                #endif
                return 0;
            }
            ENDHLSL
        }

        
    }
    CustomEditor "UnityEditor.ShaderGraph.PBRMasterGUI"
    Fallback "Hidden/InternalErrorShader"
	
}/*ASEBEGIN
Version=19102
Node;AmplifyShaderEditor.CommentaryNode;26;1041.3,3.599996;Inherit;False;212;185;Comment;1;24;;1,1,1,1;0;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;2;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;31;New Amplify Shader;5d29ac6054595c941a4f6c2b59ab8567;True;CustomPass;0;1;CustomPass;2;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;False;False;0;False;True;0;1;False;;0;False;;0;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;False;True;1;LightMode=Custom;False;False;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;3;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;31;New Amplify Shader;5d29ac6054595c941a4f6c2b59ab8567;True;ShadowCaster;0;2;ShadowCaster;1;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;False;False;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;False;True;1;LightMode=ShadowCaster;True;5;True;12;all;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;4;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;31;New Amplify Shader;5d29ac6054595c941a4f6c2b59ab8567;True;DepthOnly;0;3;DepthOnly;3;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;False;False;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;False;False;True;False;False;False;False;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;False;False;True;1;LightMode=DepthOnly;False;True;12;all;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
Node;AmplifyShaderEditor.StickyNoteNode;19;254,-635.5;Inherit;False;150;100;New Note;;1,1,1,1;全黑 -> 中心白;0;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;24;1091.3,53.59999;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.StaticSwitch;47;1483.79,324.4859;Inherit;False;Property;_Type;Type;2;0;Create;True;0;0;0;False;0;False;0;0;1;True;;KeywordEnum;2;A;B;Create;True;True;All;9;1;FLOAT;0;False;0;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT;0;False;7;FLOAT;0;False;8;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SamplerNode;5;-1866.413,-400.6565;Inherit;True;Property;_MainTex;MainTex;0;0;Create;True;0;0;0;False;0;False;-1;None;928e237a859b014449752efc1d7e69d9;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.RegisterLocalVarNode;52;-1264.703,-731.9861;Inherit;True;noise;-1;True;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;51;-1272.928,-490.5962;Inherit;True;CircleArea;-1;True;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleAddOpNode;6;383.6387,307.1178;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.StepOpNode;22;770.816,226.6369;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;53;-1272.054,-160.4367;Inherit;True;shape;-1;True;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.GetLocalVarNode;56;333.0007,38.17314;Inherit;False;52;noise;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;7;-1556.2,411.026;Inherit;False;Property;_Amount;Amount;1;0;Create;True;0;0;0;False;0;False;0;1;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.DynamicAppendNode;58;1783.691,329.1954;Inherit;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;1;2097.266,324.4086;Float;False;True;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;31;Unlit/FogUnlocker;5d29ac6054595c941a4f6c2b59ab8567;True;Forward;0;0;Forward;3;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Transparent=RenderType;Queue=Transparent=Queue=0;False;False;0;False;True;2;5;False;;10;False;;1;1;False;;10;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;True;True;0;False;;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;2;False;;True;3;False;;True;True;0;False;;0;False;;True;1;LightMode=UniversalForward;True;5;True;12;all;0;Hidden/InternalErrorShader;0;0;Standard;12;Surface;1;638125455264695757;  Blend;0;0;Two Sided;1;0;Cast Shadows;0;0;  Use Shadow Threshold;0;0;Receive Shadows;0;0;GPU Instancing;0;0;GPU Instancing Buffer;0;0;Built-in Fog;0;0;Custom Pass;0;0;Meta Pass;0;0;Vertex Position,InvertActionOnDeselection;1;0;0;4;True;False;False;True;False;;False;0
Node;AmplifyShaderEditor.RangedFloatNode;59;1957.858,165.6172;Inherit;False;Constant;_Float0;Float 0;3;0;Create;True;0;0;0;False;0;False;1;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.GetLocalVarNode;54;-496.4358,-232.2596;Inherit;True;51;CircleArea;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.ScaleAndOffsetNode;23;-827.4964,354.3142;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;2;False;2;FLOAT;-1;False;1;FLOAT;0
Node;AmplifyShaderEditor.GetLocalVarNode;57;-1282.617,931.4914;Inherit;True;53;shape;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.GetLocalVarNode;55;-407.9616,468.6338;Inherit;True;51;CircleArea;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleAddOpNode;27;-452.3806,897.3459;Inherit;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.StepOpNode;30;221.5399,967.075;Inherit;True;2;0;FLOAT;1.01;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;32;578.784,602.7762;Inherit;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
WireConnection;24;0;54;0
WireConnection;24;1;22;0
WireConnection;47;1;24;0
WireConnection;47;0;30;0
WireConnection;52;0;5;1
WireConnection;51;0;5;3
WireConnection;6;0;54;0
WireConnection;6;1;23;0
WireConnection;22;0;56;0
WireConnection;22;1;6;0
WireConnection;53;0;5;4
WireConnection;58;0;47;0
WireConnection;58;1;47;0
WireConnection;58;2;47;0
WireConnection;58;3;47;0
WireConnection;1;0;58;0
WireConnection;23;0;7;0
WireConnection;27;0;7;0
WireConnection;27;1;57;0
WireConnection;30;1;27;0
WireConnection;32;0;55;0
WireConnection;32;1;30;0
ASEEND*/
//CHKSM=B898530C680E842B6A53CC93E2F11139E45D6F0D